package com.hfh.other;

import org.junit.Test;

import java.io.*;

/**
 * @Author hfh
 * @Date 2022 09 07 11 20
 **/
public class DataStreamDemo {
    @Test
    public void test2() throws IOException {
        DataOutputStream dos = new DataOutputStream(new FileOutputStream("file\\e.txt"));

        dos.writeUTF("你好");
        dos.writeInt(2);
        dos.writeBoolean(true);
        dos.flush();
        dos.close();
    }


    @Test
    public void test1() throws IOException {
        DataInputStream ds = new DataInputStream(new FileInputStream("file\\e.txt"));

        System.out.println(ds.readUTF());
        System.out.println(ds.readInt());
        System.out.println(ds.readBoolean());

        ds.close();

    }

}
